const chalk = require('chalk')
const path = require('path')
const port = 8090

function resolve(dir) {
    return path.join(__dirname, dir)
}

module.exports = {
    publicPath: "./",
    // 关闭线上源码
    productionSourceMap: false,
    devServer: {
        hot: true,
        port,
        open:true,
        proxy: {
            '^/admin-api': {
                target: 'https://charge.diandian.work'
                // target: 'http://10.107.5.47:48088'
                // target: 'http://192.168.0.106:48088'
            },
          // https://apis.map.qq.com/ws
            '/geocoder': {
                target: ' https://apis.map.qq.com/ws',
                changeOrigin: true,
                pathRewrite: {
                    '/geocoder': '/geocoder'
                }
            }
        }
    },
    chainWebpack: (config) => {
        config.module
            .rule('svg')
            .exclude.add(resolve('src/assets/icon'))
            .end()
        config.module
            .rule('icons')
            .test(/\.svg$/)
            .include.add(resolve('src/assets/icon'))
            .end()
            .use('svg-sprite-loader')
            .loader('svg-sprite-loader')
            .options({
                symbolId: 'icon-[name]'
            })
            .end()

    },
    configureWebpack: {
        externals: {
          AMap: "AMap",
          AMapUI: "AMapUI"
        }
      }
}
